//
//  PersonalViewController.m
//  YiqiMobile
//
//  Created by henry on 13-4-5.
//  Copyright (c) 2013年 henry. All rights reserved.
//

#import "BowenMemberViewController.h"
#import "Utility.h"
#import "Config.h"
#import "BowenMemberViewCell.h"

@interface BowenMemberViewController ()
-(void) tableViewHeader;
@end

@implementation BowenMemberViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad{
    [super viewDidLoad];
    self.navigationItem.titleView=[Utility getTitleView:@"饭局集团"];
    [self tableViewHeader];
    float tableHeight=UISCREEN_HEIGHT-22-103-44;
    self.mytableView=[[UITableView alloc] initWithFrame:CGRectMake(0,103, UISCREEN_WIDTH,tableHeight) style:UITableViewStylePlain];
    self.mytableView.delegate=self;
    self.mytableView.dataSource=self;
    //self.mytableView.showsVerticalScrollIndicator=NO;
    self.mytableView.separatorStyle=UITableViewCellAccessoryDisclosureIndicator;
    [self.view addSubview:self.mytableView];
    self.arrayList=[NSMutableArray array];
    [self.arrayList addObject:@"国际在线消息："];
    [self.arrayList addObject:@"国际在线消息：据外交部网站消息，对于越南外交部称中国船只在西沙海域向越南渔船开枪射击一事，中国外交部发言人洪磊在26日的例行记者会上表示，越南渔船进入中国西沙海域进行非法作业，中方采取行动是必要的、正当的外交部发言人洪磊在26日的例行记者会上表示，越南渔船进入中国西沙海域进行非法作业，中方采取行动是必要的、正当的"];
    [self.arrayList addObject:@"国际在线消息：据外交部网站消息，对于越南外交部称中国船只在西沙海域向"];
    [self.arrayList addObject:@"国际在线消息：据外交部网站消息，对于越南外交部称中国船只在西沙海域向越"];
    for (int i=0;i<10;i++) {
        [self.arrayList addObject:@"国际在线消息：据外交部网站消息，对于越南外交部称中国船只在西沙海域向越南渔船开枪射击一事，中国外交部发言人洪磊在26日的例行记者会上表示，越南渔船进入中国西沙海域进行非法作业，中方采取行动是必要的、正当的"];
    }


  
	// Do any additional setup after loading the view.
}

-(void) tableViewHeader{
    UIView *topView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 103)];
    topView.backgroundColor=[UIColor colorWithPatternImage:[Utility imageNamed:@"personaltop_bg.png"]];
    UIImageView *personalLogo=[[UIImageView alloc] initWithFrame:CGRectMake(16, 14, 82, 82)];
    personalLogo.image=[Utility imageNamed:@"pesonalLogo@2x.png"];
    [topView addSubview:personalLogo];
    UILabel *label1=[Utility detailTextLabel:CGRectMake(106, 20, 180, 20) andFontSize:15.0];
    label1.textColor=UIColorFromRGB(0x000000);
    label1.text=@"Apple";
    [topView addSubview:label1];
    UILabel *label2=[Utility detailTextLabel:CGRectMake(106, 56, 180, 16) andFontSize:12.0];
    label2.textColor=UIColorFromRGB(0x000000);
    label2.text=@"在博文:懒散的猫";
    [topView addSubview:label2];
    UILabel *label3=[Utility detailTextLabel:CGRectMake(106, 74, 180, 16) andFontSize:12.0];
    label3.text=@"供稿:15篇";
    label3.textColor=UIColorFromRGB(0x000000);
    [topView addSubview:label3];
    [self.view addSubview:topView];
}




- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.arrayList count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
        UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
        return cell.frame.size.height;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellIdentity = @"personalViewCell";
    
    BowenMemberViewCell *cell = (BowenMemberViewCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentity];
    if (cell ==  nil) {
        cell = [[BowenMemberViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentity];
    }
   
    UIFont *font=[UIFont fontWithName:FONT_FAMILY size:15.0f];
    CGSize size=[Utility getStringSize:[self.arrayList objectAtIndex:indexPath.row] font:font withMaxSize:CGSizeMake(290, 100)];
    if ((indexPath.row) %2==0) {
        cell.frame=CGRectMake(0, 0, 320, size.height+80);
        cell.content.hidden=NO;
        cell.imageLogo.hidden=YES;
        cell.content.frame=CGRectMake(15, 39, 290, size.height);
        cell.content.numberOfLines=size.height/20;
        cell.content.text=[self.arrayList objectAtIndex:indexPath.row];
        
    }else{//图片85*58
        cell.frame=CGRectMake(0, 0, 320, 110);
        cell.content.hidden=YES;
        cell.imageLogo.hidden=NO;
        cell.imageLogo.image=[Utility imageNamed:@"pesonalLogo.png"];

    }
    cell.detalContent1.frame=CGRectMake(15, 17, 290, 14);
    cell.detalContent2.frame=CGRectMake(15, cell.frame.size.height-27, 290, 14);
    cell.detalContent1.text=[NSString stringWithFormat:@"%@  %@供稿  阅读:%@",@"2013-1-23",@"Apple",@"156"];
    cell.detalContent2.text=[NSString stringWithFormat:@"阅读%@  收藏%@  评论:%@   评论:%@",@"2013-1-23",@"Apple",@"156",@"10"];
         
    return cell;
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
